package model;

import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "VOYAGE_TRAIN")
public class VoyageTrain  {
	private int id;
	private VilleTrain GareDepart;
	private VilleTrain GareArrivee;
	private String DateDepart;
	private String HeureDepart;
	private List<HoraireTrain> horairesTrain;

	public VoyageTrain(VilleTrain gareDepart, VilleTrain gareArrivee,
			String dateDepart) {
		GareDepart = gareDepart;
		GareArrivee = gareArrivee;
		DateDepart = dateDepart;
	}

	public VoyageTrain() {
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "VOYAGE_TRAIN_ID")
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name = "GARE_DEPART")
	public VilleTrain getGareDepart() {
		return GareDepart;
	}

	public void setGareDepart(VilleTrain gareDepart) {
		GareDepart = gareDepart;
	}

	@ManyToOne
	@JoinColumn(name = "GARE_ARRIVEE")
	public VilleTrain getGareArrivee() {
		return GareArrivee;
	}

	public void setGareArrivee(VilleTrain gareArrivee) {
		GareArrivee = gareArrivee;
	}

	@Column(name = "DATEDEPART")
	public String getDateDepart() {
		return DateDepart;
	}

	public void setDateDepart(String dateDepart) {
		DateDepart = dateDepart;
	}

	@Column(name = "HEUREDEPART")
	public String getHeureDepart() {
		return HeureDepart;
	}

	public void setHeureDepart(String heureDepart) {
		HeureDepart = heureDepart;
	}

	@OneToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER, mappedBy = "voyageTrain")
	public List<HoraireTrain> getHorairesTrain() {
		return horairesTrain;
	}

	public void setHorairesTrain(List<HoraireTrain> horairesTrain) {
		this.horairesTrain = horairesTrain;
	}

}
